/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bff.mpd.utils;

import com.bff.mpd.musicjukebox.lib.JukeboxProperties;
import java.util.Comparator;
import org.bff.javampd.objects.MPDItem;

/**
 *
 * @author bill
 */
public class MPDComparator implements Comparator<MPDItem> {

    private boolean includeThe;

    public MPDComparator() {
        includeThe = JukeboxProperties.getInstance().isIncludeThe();
    }

    @Override
    public int compare(MPDItem t1, MPDItem t2) {
        String name1 = includeThe ? t1.getName().toUpperCase() : t1.getName().toUpperCase().replaceAll("^THE ", "").toUpperCase();
        String name2 = includeThe ? t2.getName().toUpperCase() : t2.getName().toUpperCase().replaceAll("^THE ", "").toUpperCase();

        return name1.compareTo(name2);
    }

}
